package com.service.calculate;

import com.service.bean.other.VehicleScalar;

public class Road_ProcessPool {
	
	/**
	 * GPS数据计算
	 * @param vehicleScalar 车辆的计算线程和实时数据的累计数量
	 * @param deviceNo 设备号
	 */
	public static void scalarCal(VehicleScalar vehicleScalar,String deviceNo) {
		synchronized(vehicleScalar){
			Thread thread = getScalarCaler(vehicleScalar,deviceNo);
			if (thread != null) {
				thread.start();
			}
		}
		
	}
	/**
	 * 从对象中获取该车所对应的线程
	 * @param vehicleScalar 
	 * @param deviceNo 
	 * @return Thread
	 */
	public static Thread getScalarCaler(VehicleScalar vehicleScalar,String deviceNo) {		
		if (vehicleScalar.ScalarCalThread == null || !vehicleScalar.ScalarCalThread.isAlive()) {
			vehicleScalar.ScalarCalThread = new Thread(new Road_ScalarCal(), deviceNo);
			return vehicleScalar.ScalarCalThread;
		} else {
			return null;
		}
	}
}
